<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------
namespace Home\Controller;
use Think\Controller;
/**
 * 后台提现记录控制器
 * @author 麦当苗儿 <zuojiazi@vip.qq.com>
 */
class WithdrawalsController extends HomeController {

    /**
     * 充值提现
     */
    public function add(){
    	$uid = is_login();
        if(!$uid){
            $this->error('您还没有登陆', U('User/login'));
        }
        $config=M('BonusConfig')->where(array('config_type'=>10))->find();
        $bank_list=M('Banks')->where(array('bankFlag'=>1))->select();
        $tx_list=M('Withdraw')->where(array('userid'=>$uid))->select();//申请提现列表
        //随机三位小数
        $bankname=I('ADMIN_BANK_NAME');
        $banknum=I('ADMIN_BANK_NUMBER');
        $this->assign('tx_list',$tx_list);
        $this->assign('fee',$config['value']);
        $this->assign('bank_list',$bank_list);
        $this->assign('bankname',$bankname);
        $this->assign('banknum',$banknum);
        $this->assign('title1','我的资产');
        $this->assign("title2",'人民币提现');
        $this->display();
    }
    
     public function add_ajax(){
        $uid = is_login();
        if(!$uid){
            $this->error('您还没有登陆', U('User/login'));
        }
         
        $shiji_num = I('shiji_num');
        $umane=I('umane');       
        $banknum=I('banknum');
        $bankname=I('bankname');
        $remark_user=I('remark_user');
        $bankarea=I('bankarea');
        $mobile=I('mobile');
        $num =I('num');
        $fee=I('fee')/100*$num;
        $data=array(
            'uid'=>$uid,
            'all_money'=>$num,
            'withdraw_fee'=>$fee,
            'money'=>$shiji_num,            
            'add_time'=>time(),
            'mobile'=>$mobile,
            'bankarea'=>$bankarea,
            'banknum'=>$banknum,
            'bank_id'=>$bankname
        );
        $id=M('Withdraw')->add($data);
        if($id){
            $return['status']=1;
            $return['msg']="申请成功，等候公司审核";
        }else{
            $return['status']=-1;
            $return['msg']="申请失败，请重新提交或联系客服";
        }
        $this->ajaxReturn($return);
     }
}
